/**
 * Date:2021年9月10日 上午10:50:15
 * Copyright (c) 2021, www.bwbroad.com All Rights Reserved
 */
package com.example.demo.config;

//import org.mengyun.tcctransaction.recovery.DefaultRecoverFrequency;
//import org.mengyun.tcctransaction.repository.JdbcTransactionRepository;
//import org.mengyun.tcctransaction.serializer.JacksonTransactionSerializer;


//@Configuration
public class TccConfig {

//    @Primary
//    @Bean(name = "datasource")
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public DataSource datasource() {
//        return DataSourceBuilder.create().build();
//    }
//
//    @Bean(name = "datasourceTcc")
//    @ConfigurationProperties(prefix = "spring.datasource-tcc")
//    public DataSource datasourceTcc() {
//        return DataSourceBuilder.create().build();
//    }
//
////
////	<bean id="transactionRepository"
////		      class="org.mengyun.tcctransaction.spring.repository.JdbcTransactionRepository">
////		    <property name="dataSource" ref="dataSource"/>
////		    <property name="domain" value="TCC:HTTP:CAPITAL:"/>
////    </bean>
//
//    @Bean("transactionRepository")
//    public TransactionRepository transactionRepository() {
//        var serializer = new JacksonTransactionSerializer();
//        JdbcStoreProperties jdbcStoreProperties = new JdbcStoreProperties();
//        jdbcStoreProperties.setJdbcUrl("jdbc:mysql://127.0.0.1:8023/tcc-transaction3?useSSL=false&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8");
//        jdbcStoreProperties.setPassword("root");
//        jdbcStoreProperties.setUsername("root");
//        jdbcStoreProperties.setDriverClass("com.mysql.cj.jdbc.Driver");
//        StoreConfig config = new ServerConfig();
//        config.se
//        TransactionRepository r = new DefaultTransactionRepository(
//                "TCC:HTTP:ORDER:", serializer,
//                new JdbcTransactionStorage(
//                        new TccTransactionStoreSerializer(),
//                        ));
////        r.setDataSource(datasourceTcc());
////        r.setDomain();
////        r.setSerializer(new JacksonTransactionSerializer());
//        return r;
//    }
//
////<bean id="recoverFrequency" class="org.mengyun.tcctransaction.recovery.DefaultRecoverFrequency">
////    <property name="maxRetryCount" value="30"/>
////    <property name="recoverDuration" value="30"/>
////    <property name="cronExpression" value="0/15 * * * * ?"/>
////    <property name="fetchPageSize" value="200"/>
////</bean>
//
//    @Bean("recoverFrequency")
//    public DefaultRecoverFrequency recoverFrequency() {
//        DefaultRecoverFrequency r = new DefaultRecoverFrequency();
//        r.setMaxRetryCount(30);
//        r.setRecoverDuration(30);
//        r.setCronExpression("0/15 * * * * ?");
//        r.setFetchPageSize(200);
//        return r;
//    }
//
//    //	RestTemplate 配置
//    @Bean
//    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
//        return new RestTemplate(factory);
//    }
//
//    @Bean
//    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
//        // 创建一个 httpCilent 简单工厂
//        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
//        // 设置连接超时15s
//        factory.setConnectTimeout(15000);
//        // 设置读取超时5s
//        factory.setReadTimeout(5000);
//        return factory;
//    }

}
